package com.gzx.plugin.tjzy.modular.phone.complaint.controller;

import com.gzx.plugin.tjzy.modular.phone.complaint.bo.GzxComplaintPhoneAddBo;
import com.gzx.plugin.tjzy.modular.phone.complaint.bo.GzxComplaintPhoneQueryBo;
import com.gzx.plugin.tjzy.modular.phone.complaint.service.GzxComplaintPhoneService;
import com.gzx.plugin.tjzy.modular.phone.complaint.vo.GzxComplaintPhoneVo;
import com.gzx.plugin.tjzy.modular.phone.dto.GzxPhoneStatusDto;
import com.gzx.plugin.tjzy.modular.phone.error.bo.GzxErrorPhoneAddBo;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
import vip.xiaonuo.common.mvc.controller.BaseController;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * @author zjt
 * @description
 * @date 2025/6/12 10:32
 */
@RestController
@RequestMapping("/tjzy/phone/complaint")
public class GzxComplaintPhoneController extends BaseController<GzxComplaintPhoneAddBo, GzxComplaintPhoneVo, GzxComplaintPhoneQueryBo, GzxComplaintPhoneService> {

    public GzxComplaintPhoneController(GzxComplaintPhoneService baseService) {
        super(baseService);
    }

    /**
     * 投诉手机号导入
     */
    @PostMapping("/importExcel")
    public CommonResult<String> importExcel(@RequestPart("complaintPhoneAddBo") GzxComplaintPhoneAddBo bo, @RequestPart("multipartFile") MultipartFile multipartFile) {
        return CommonResult.data(baseService.importExcel(bo, multipartFile));
    }

    /**
     * 校验投诉手机号
     */
    @GetMapping("/verifyComplaint/{phone}")
    public CommonResult<List<GzxPhoneStatusDto>> verifyComplaint(@PathVariable String phone) {
        //获取登录人的信息
        SaBaseLoginUser user = StpLoginUserUtil.getLoginUser();
        String userId = user.getId();
        String tenantId = user.getTenantId();
        List<GzxPhoneStatusDto> list = baseService.verifyComplaint(List.of(phone), userId, tenantId);
        return CommonResult.data(list);
    }
}
